package com.clusterswisdom.horn.api.tmall.action.scitem;

import java.util.HashMap;

import com.alibaba.fastjson.JSONObject;
import com.clusterswisdom.horn.api.ioc.HornAction;
import com.clusterswisdom.horn.api.ioc.HornResponse;
import com.clusterswisdom.horn.api.ioc.api.ApiConfig;
import com.clusterswisdom.horn.api.tmall.action.AbstractTmallAction;
import com.clusterswisdom.horn.api.tmall.action.scitem.ThreadOfStore.KeepToDb;

public class ExtendItemStoreAction extends AbstractTmallAction implements HornAction{
	@Override
	public HornResponse execute(ApiConfig config, JSONObject param)
			throws Exception {
		//表名
		String tableName ="t_daystock";
		
		boolean isEnd = KeepToDb.setIntoDb(param, tableName);
		
		//这一步应该与发送成功同步
		if(isEnd){
			HashMap<String,String> caiAndId = KeepToDb.getDataFromTmall(tableName);
			
			KeepToDb.updateItemByItemId(caiAndId, tableName);
			
			KeepToDb ktd = new KeepToDb();
			ktd.KeepToTmall(tableName);
			ktd.initialToTmall(tableName);
		}
		
		return new HornResponse(true, "成功");
	}
}
